# vim: ts=4:sw=4:syntax=perl

use gri_secmgr qw(get_user_name);
# CSS-V1

sub mm_outstanding_approvals_summary_list($) {
my $order_by=shift;

	my $req_dir=$::GRI_FRONTEND->get_directory("requests");
	my $rdb=new gri2_requests("$req_dir/requests.db");
	my ($rc,$str);
	if(!defined($rdb)) {
		($rc,$str)=gri2_requests::error();
		return html_error("Failed to open requests database: $str",1);
	}
	# Grab the request information first before worrying about sorting this stuff.
	my $open_approvals=$rdb->my_outstanding_approvals(get_user_name());

	if($open_approvals->{error}) {
		return html_error($open_approvals->{error});
	}
	# Sort any records first

	# Plop the records in the table now...

	my $s=""; my $row=0;
	for my $_crec (@{$open_approvals->{records}}) {
		my $crec=$rdb->decode($_crec);
		my $class="gri_odd";
		$class="gri_even" if $row%2==0;
		$s.="<tr id=$class><td class=gri_cell>$crec->{id}</td>";
		my $xx=$::GRI_FRONTEND->datetime_str($crec->{raised});
		$s.="<td class=gri_cell>$xx</td>";
		my $em=$::GRI_FRONTEND->get_user_email_address($crec->{user});
		my $ss="";
		$ss=" - $em" if $em;
		$s.="<td class=gri_cell>$crec->{user}$ss</td>";
		$s.="<td class=gri_cell>$crec->{object}</td>";
		# A link to view more details...
		my $link=my $l=link_to_str("stdlink","View","outstanding_approval_request_view","id=$crec->{id}");
		$s.="<td class=gri_cell-right>$link</td></tr>\n";
		$row++;
	}
	return $s;
}

